package com.ojoin.trade.t0loan_core.web.dao.impl;

import java.util.HashMap;

import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Repository;

import com.ojoin.trade.common.exception.BusinessException;
import com.ojoin.trade.common.exception.DaoException;
import com.ojoin.trade.common.web.dao.impl.BaseDaoImpl;
import com.ojoin.trade.t0loan_core.web.dao.TbT0StatusOfPosTranscationDao;
import com.ojoin.trade.t0loan_core.web.domain.TbT0StatusOfPosTranscation;

@Repository
public class TbT0StatusOfPosTranscationDaoImpl extends
		BaseDaoImpl<TbT0StatusOfPosTranscation> implements
		TbT0StatusOfPosTranscationDao {

	public SqlSession getSqlSession() {
		return this.sqlSessionTemplate;
	}

	public int updatePosTransStatusInfoReturnStatus(Integer joinuserid, String transdate)
			throws BusinessException {
		String mapMethodName = "updatePosTransStatusInfoReturnStatus";
		try {
			HashMap<String, Object> paramMap = new HashMap<String, Object>(); 
			paramMap.put("joinuserid", joinuserid);
			paramMap.put("transdate", transdate);
			
			return getSqlSession()
					.update(getSqlName(mapMethodName), paramMap);
		} catch (Exception e) {
			throw new DaoException(String.format("根据用户主键和交易日期更新交易还款状态出错！语句：%s",
					getSqlName(mapMethodName)), e);
		}
	}

	public int updatePosTransStatusInfoUsedByLoanStatus(Integer joinuserid, String transdate) throws BusinessException {
		String mapMethodName = "updatePosTransStatusInfoUsedByLoanStatus";
		try {
			HashMap<String, Object> paramMap = new HashMap<String, Object>(); 
			paramMap.put("joinuserid", joinuserid);
			paramMap.put("transdate", transdate);
			
			return getSqlSession()
					.update(getSqlName(mapMethodName), paramMap);
		} catch (Exception e) {
			throw new DaoException(String.format("根据用户主键和交易日期更新交易放款状态出错！语句：%s",
					getSqlName(mapMethodName)), e);
		}
	}

	@Override
	public void insertIntoPosTransStatusInfo(Integer joinuserid, String transdate) throws BusinessException {
		String mapMethodName = "insertIntoPosTransStatusInfo";
		try {
			HashMap<String, Object> paramMap = new HashMap<String, Object>(); 
			paramMap.put("joinuserid", joinuserid);
			paramMap.put("transdate", transdate);
			
			getSqlSession()
					.selectList(getSqlName(mapMethodName), paramMap);
		} catch (Exception e) {
			throw new DaoException(String.format("批量插入pos交易主键及交易放款状态出错！语句：%s",
					getSqlName(mapMethodName)), e);
		}
	}
}
